<%@ page contentType="text/html; charset=utf-8"%>

<div id="vlanGradeDiv" style="width: 100%;display: none;">




	<div>
		<span style="margin-top: 16px;">开始时间：</span><input type="text" id="vlanGradeDate"  style="margin-top: 7px;">
			<select id="vlanGradeDateType" style="margin-top: 7px;width: 60px;height: 28px;font-size: 14px;">
			<option value="按日">按日</option>
			<option value="按周">按周</option>
			<option  selected="selected" value="按月">按月</option>
		</select>
		<input id="vlanGradeCompanyText" type="text" style="width: 200px;margin-top: 7px;display: none;"></input>
		 <select id="vlanGradeCompanyTextSelect" onchange="vlant(this)"
			style="margin-top: 7px; height: 28px; font-size: 14px;z-index: 1;">
			<option selected="selected" value="所有数据">所有数据</option>
			<option value="公司查询">公司查询</option>
		</select> 
		 <input type="button" onclick="getVlanGrade()" style="width: 100px;margin-left: 30px;" class="btn btn-primary m_r" value="查询">
		 	<input type="button" onclick="exportReportVlan()" style="width: 100px;" class="btn btn-primary m_r" value="导出报表"></input>
	</div>
	<div>
	
	   <table class="table table-striped table-bordered" id="vlanGradeTable"> </table>
	
	
	</div>
	
</div>
<script>

function vlant(obj) {
	if (obj.value == "所有数据") {
		$("#vlanGradeCompanyText").hide();
	} else{
		$("#vlanGradeCompanyText").show();
	}
}
var vlanGradeDate,vlanGradeDateType,vlanGradeCompanyTextSelect,vlanGradeCompanyText;
	$(function() {
		$("#vlanGradeDate").datepicker();
		
		iniVlanGradeData();
		
	});
	
	function iniVlanGradeData(){
		
	 $("#vlanGradeDate").val(date2str(new Date(),"yyyy-MM-dd"));

	 getVlanGrade();
	}
	
	function getVlanGrade(){
		
		
	vlanGradeDate = $("#vlanGradeDate").val();
	vlanGradeDateType = $("#vlanGradeDateType").val();
		
	vlanGradeCompanyTextSelect = $("#vlanGradeCompanyTextSelect").val();
	vlanGradeCompanyText = $("#vlanGradeCompanyText").val();
	if(vlanGradeDate==null||vlanGradeDate==""){
		alert("请选择时间");
		return;
	}
	
	showCommonDiv();
		$.post("getData", {"types":"vlanGrade", 
			"vlanGradeDate":vlanGradeDate,"vlanGradeDateType":vlanGradeDateType,"vlanGradeCompanyTextSelect":vlanGradeCompanyTextSelect,"vlanGradeCompanyText":vlanGradeCompanyText},
				   function(data){
				closeCommonDiv();
						if(data!=null){
							
							setVlanGradeData(data);	
						}
				
				   },"json");
		
	}
	
	
	function setVlanGradeData(data){
		var tableVal = "<thead><tr><th>排名</th><th>网页测试得分</th><th>时延得分</th><th>抖动得分</th><th>丢包得分</th><th>网页测试次数</th><th>下载测试得分</th><th>下载测试次数</th><th>公司_街道小区</th><th>时间</th> </tr></thead><tbody >";
		for(var i = 0 ;i < data.length;i++){
			var obj = data[i];
			
				if(i==0){
					tableVal = tableVal+"<tr><td>"+(i+1)+"</td><td>"+obj.webGrade+"</td><td>"+obj.webtimedelayGrade+"</td><td>"+obj.webShakeGrade+"</td><td>"+obj.weblostRateGrade+"</td><td>"+obj.webTestCount+"</td><td>"+obj.downFileGrade+"</td><td>"+obj.downFileTestCount+"</td><td>"+obj.vlanId+"</td><td rowspan='"+data.length+"' style='text-align:center'>"+obj.time+"</td></tr>";	
				}else{
					
					tableVal = tableVal+"<tr><td>"+(i+1)+"</td><td>"+obj.webGrade+"</td><td>"+obj.webtimedelayGrade+"</td><td>"+obj.webShakeGrade+"</td><td>"+obj.weblostRateGrade+"</td><td>"+obj.webTestCount+"</td><td>"+obj.downFileGrade+"</td><td>"+obj.downFileTestCount+"</td><td>"+obj.vlanId+"</td></tr>";	
					
				}			
				
			
		}
		tableVal = tableVal+"</tbody>";
		
		$("#vlanGradeTable").html(tableVal);
		
	}
	
	
	function exportReportVlan(){
		
		getVlanGrade();
		if(vlanGradeDate==null||vlanGradeDate==""){

			return;
		}
		showCommonDiv();
				$.post("exportReport", {"types":"vlanGrade","vlanGradeDate":vlanGradeDate,"vlanGradeDateType":vlanGradeDateType,"vlanGradeCompanyTextSelect":vlanGradeCompanyTextSelect,"vlanGradeCompanyText":vlanGradeCompanyText},
				   function(data){
					closeCommonDiv();
					if(data!="false"){
						window.location.href="exportReport?types=downFile&&fileName="+data; 
					}
				},"json");
		
	}
	
</script>





